<?php
class BC_Colorswatch_Block_Adminhtml_Attribute_Tab
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface {
    /**
     * Set the template for the block
     *
     */
    public function _construct()
    {

        parent::_construct();
        $this->setTemplate('bc_colorswatch/bc_colorswatch.phtml');
    }
    /**
     * Retrieve the label used for the tab relating to this block
     *
     * @return string
     */
    public function getTabLabel()
    {
        return $this->__('Bluecom Colorswatch');
    }
    /**
     * Retrieve the title used by this tab
     *
     * @return string
     */
    public function getTabTitle()
    {
        return $this->__('Bluecom Colorswatch');
    }
    /**
     * Determines whether to display the tab
     * Add logic here to decide whether you want the tab to display
     *
     * @return bool
     */
    public function canShowTab()
    {
        $id = $this->getRequest()->getParam('attribute_id');
        if(!$id)
            return false;
        else{
            $attr = Mage::registry('entity_attribute');
            if($attr->getIsGlobal() and $attr->getFrontendInput()=='select' and $attr->getIsConfigurable())
                return true;
            return false;
        }
    }
    /**
     * Stops the tab being hidden
     *
     * @return bool
     */
    public function isHidden()
    {
        return false;
    }
    public function bcGetAllOption(){
        $id = $this->getRequest()->getParam('attribute_id');
        if(!$id)
            return array();
        else{
            $attr = Mage::registry('entity_attribute');
            $options = $attr ->getSource()->getAllOptions(false);
            return $options;
        }
    }
    public function bcGetAllOptionData($attribute_id){
        if(!$attribute_id) return null;
        $swatchModel = Mage::getModel('colorswatch/colorswatch')->load($attribute_id, 'attribute_id');
        if(!$swatchModel) return null;
        $data = unserialize($swatchModel->getContent());
        return $data;
    }
}